package
{
	
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageDisplayState;
	import flash.display.StageQuality;
	import flash.display.StageScaleMode;
	import flash.display3D.Context3DProfile;
	import flash.events.Event;
	import flash.events.FullScreenEvent;
	import flash.events.KeyboardEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.ui.Keyboard;
	
	import starling.core.Starling;
	import starling.events.Event;
	
	[SWF( width="640", height="360", backgroundColor="#000000", frameRate="60")]
	public class FullscreenImageTest extends Sprite
	{
		private var mStarling:Starling;
		public function FullscreenImageTest()
		{
			loaderInfo.addEventListener(flash.events.Event.COMPLETE, onLoadComplete);
		}
		
		protected function onLoadComplete(event:flash.events.Event):void
		{
			stage.frameRate = 60;
			stage.quality = StageQuality.LOW;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
			mStarling = new Starling(AppRoot, stage);
			mStarling.antiAliasing = 1;
			mStarling.showStats = true;
			mStarling.start();
			
			stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullscreenChanged);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
		}
		
		protected function onKeyDown(event:KeyboardEvent):void
		{
			if (event.controlKey)
			{
				if (event.keyCode == Keyboard.F)
				{
					if (stage.displayState == StageDisplayState.NORMAL)
					{
						stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
					}
					else
					{
						stage.displayState = StageDisplayState.NORMAL;
					}
				}
			}
		}
		
		protected function onFullscreenChanged(event:FullScreenEvent):void
		{
			mStarling.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
			mStarling.stage.stageWidth = 640;
			mStarling.stage.stageHeight = 360;
		}		
		
	}
}